package org.kzwl.book.controller.app;


import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.kzwl.comm.pojo.ResponseData;
import org.kzwl.comm.pojo.bo.category.CategoryBasic;
import org.kzwl.comm.pojo.bo.comment.AddCommentBO;
import org.kzwl.comm.pojo.bo.comment.QueryCommentBO;
import org.kzwl.comm.pojo.dto.comment.CommentDTO;
import org.kzwl.entity.app.Category;
import org.kzwl.entity.app.Comment;
import org.kzwl.service.app.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 张国伟/郭家恒
 * @since 2020-09-10
 */
@RestController
@RequestMapping("/comment")
@Api("评论")
public class CommentController {

    @Autowired
    CommentService commentService;

    @ApiOperation(value = "添加评论",notes = "cuUserId(用户编号)--必填 cuCommentText(内容)--必填 cuUserScore(分数，如果是回复评论，不填) cuExtId(评论对象，书籍ID)--必填 cuCommentParent(父级id 如果是评论书籍，为0，回复某评论，为评论id)--必填")
    @PostMapping("/addComment")
    public ResponseData<Void> addComment(@RequestBody AddCommentBO bo) {
        commentService.addComment(bo);
        return new ResponseData<>();
    }

    @ApiOperation(value = "查询书籍评论",notes = "cuExtId(书籍id)--必填")
    @PostMapping("/queryComment")
    public ResponseData<List<CommentDTO>> queryComment(@RequestBody QueryCommentBO bo) {
        List<CommentDTO> list = commentService.queryComment(bo);
        return new ResponseData<>(list);
    }

}
